feat: support kafka consumer for pubsub scenario#6995
Closed
bzp2010 wants to merge 98 commits intoapache:masterfrom
Closed
feat: support kafka consumer for pubsub scenario#6995bzp2010 wants to merge 98 commits intoapache:masterfrom
bzp2010 wants to merge 98 commits intoapache:masterfrom
Conversation
spacewander
reviewed
May 11, 2022
| -- Its second return value is a string type error message, no need to return when | ||
| -- no error exists. | ||
| -- | ||
| -- @function core.pubsub.on |
| end | ||
|
|
||
| -- skip this loop for non-fatal errors | ||
| log.error("failed to receive websocket frame: "..err) |
Member
There was a problem hiding this comment.
Suggested change
| log.error("failed to receive websocket frame: "..err) | |
| log.error("failed to receive websocket frame: ", err) |
| -- terminate the event loop when a fatal error occurs | ||
| if ws.fatal then | ||
| ws:send_close() | ||
| return "websocket server: "..err |
Member
There was a problem hiding this comment.
Better to use break in the while loop and handle the error in the same place
| -- the pub-sub messages use binary, if the message is not | ||
| -- binary, skip this message | ||
| if raw_type ~= "binary" then | ||
| goto continue |
Member
There was a problem hiding this comment.
Better to add warn log for unexpected input
| goto continue | ||
| end | ||
|
|
||
| local data = pb.decode("PubSubReq", raw_data) |
Member
There was a problem hiding this comment.
Should we check decode error?
| "enable_tls": true, | ||
| "ssl_verify": true, | ||
| "enable_sasl": true, | ||
| "sasl_username": "user", |
Member
There was a problem hiding this comment.
Please update the example when the code part is accepted.
| ngx.say(body) | ||
| } | ||
| } | ||
| --- error_code: 200 |
Member
There was a problem hiding this comment.
We don't need to check the default error_code
| pb.option("int64_as_string") | ||
| local pubsub_protoc = protoc.new() | ||
| pubsub_protoc:addpath("apisix/include/apisix/model") | ||
| local ok, err = pcall(pubsub_protoc.loadfile, pubsub_protoc, "pubsub.proto") |
| --- config | ||
| location /t { | ||
| content_by_lua_block { | ||
| local protoc = require("protoc") |
Member
There was a problem hiding this comment.
We can exact the common part into helper, and put it in https://github.com/apache/apisix/tree/master/t/lib?
| 1failed to fetch message, topic: not-exist, partition: 0, err: not found topic | ||
| 2offset: 0 | ||
| 3offset: 30 | ||
| 4offset: 14 msg: testmsg15 |
Member
There was a problem hiding this comment.
Let's add a comment about where the msg is from
This was referenced May 11, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Support kafka consumers for publish-subscribe scenarios.
Implement proposal # (6874)
Checklist